package com.cloud.rou.im.connection.container.listen;

import com.cloud.rou.im.connection.container.event.SessionEvent;
import com.cloud.rou.im.connection.container.manager.SessionManager;
import com.cloud.rou.im.connection.container.manager.SessionManagerHolder;
import com.cloud.rou.im.connection.container.session.Session;
import io.netty.channel.ChannelHandlerContext;

/**
 * <p></p>
 *
 * @author GaoShuangWen
 */
public class DestroyedSessionListener implements SessionListener {
    @Override
    public void sessionCreated(SessionEvent event) {
        // do nothing
    }

    @Override
    public void sessionDestroyed(SessionEvent event) {
        Session session = event.getSession();
        ChannelHandlerContext ctx = session.getConnection().getCtx();
        SessionManagerHolder.getManager().removeConnectSession(session);
        ctx.close();
    }
}
